package com.example.q_kang.hhh.home;


import com.example.q_kang.hhh.R;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.shizhefei.mvc.MVCCoolHelper;
import com.shizhefei.view.coolrefreshview.CoolRefreshView;
import com.sskj.base.MVPActivity;
import com.example.q_kang.hhh.home.MacIntegralDetailPresenter;
import com.sskj.base.adapter.MyFragmentPagerAdapter;
import com.sskj.base.adapter.slimadapter.IViewInjector;
import com.sskj.base.adapter.slimadapter.SlimAdapter;
import com.sskj.base.adapter.slimadapter.SlimInjector;
import com.sskj.base.base.App;
import com.sskj.base.bean.BuyDakuanListBean;
import com.sskj.base.bean.MoneyListBean;
import com.sskj.base.data.TabEntity;
import com.sskj.base.mvchelper.ModelRx2DataSource;
import com.sskj.base.utils.DateUtil;
import com.sskj.base.view.ToolBarLayout;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import io.reactivex.Flowable;

/**
 * @author Hey
 * Create at  2019/04/10
 */
public class MacIntegralDetailActivity extends MVPActivity<MacIntegralDetailPresenter> {
    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.coolRefreshView)
    CoolRefreshView coolRefreshView;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    private SlimAdapter<MoneyListBean.MoneyBean> slimAdapter;
    private MVCCoolHelper<List<MoneyListBean.MoneyBean>> mvcHelper;

    private String mid;

    @Override
    public int getLayoutId() {
        return R.layout.activity_mac_integra_ldetail;
    }

    @Override
    public MacIntegralDetailPresenter getPresenter() {
        return new MacIntegralDetailPresenter();
    }

    @Override
    public void initView() {
        String title = getIntent().getStringExtra("title");
        mid = getIntent().getStringExtra("mid");
        toolbar.setTitle(title);
        toolbar.setLeftButtonOnClickListener(view -> finish());
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        slimAdapter = SlimAdapter.create().register(R.layout.item_mac_type, new SlimInjector<MoneyListBean.MoneyBean>() {
            @Override
            public void onInject(MoneyListBean.MoneyBean data, IViewInjector injector) {
                injector.text(R.id.tv_remark, App.INSTANCE.getString(R.string.appJavaMacIntegralDetailActivity3) + data.getNote())
                        .text(R.id.tv_money, data.getMoney())
                        .text(R.id.tv_type, data.getType_name())
                        .text(R.id.tv_date, DateUtil.getDateFormat(Long.valueOf(data.getZf_time()) * 1000, DateUtil.PATTERN_J));
            }
        }).attachTo(recyclerView).updateData(new ArrayList());
        mvcHelper = new MVCCoolHelper<>(coolRefreshView);
        ModelRx2DataSource<MoneyListBean.MoneyBean> dataSource = new ModelRx2DataSource<>(
                (ModelRx2DataSource.OnLoadSource<MoneyListBean.MoneyBean>)
                        page -> mPresenter.getBuyWaitDaKuan(mid, page), 10);
        mvcHelper.setDataSource(dataSource);
        mvcHelper.setAdapter(slimAdapter);
        mvcHelper.refresh();
    }

    @Override
    public void initData() {

    }

    public static void start(Context context, String title, String mid) {
        Intent intent = new Intent(context, MacIntegralDetailActivity.class);
        intent.putExtra("title", title);
        intent.putExtra("mid", mid);
        context.startActivity(intent);
    }

}
